package com.jyh.homework;

import java.io.*;

/**
 * @Author JYH
 * @Date 2024/8/5 17:30
 * @Description 把如下这些数据存放到一个data.txt文件中，并且再次读取显示
                int a = 10;
                char c = 'a';
                double d = 2.5;
                boolean b = true;
                String str = "软帝联合";
 */
public class Homework3 {
    public static void main(String[] args) throws IOException {
        int a = 10;
        char c = 'a';
        double d = 2.5;
        boolean b = true;
        String str = "软帝联合";
        BufferedReader br = new BufferedReader(new FileReader("D:\\course\\02-JavaSE-plus\\day9-IO流\\testIO\\data.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\course\\02-JavaSE-plus\\day9-IO流\\testIO\\data.txt"));
        bw.write("int a ="+a+";\n");
        bw.write("char c ="+c+";\n");
        bw.write("double d ="+d+";\n");
        bw.write("boolean b ="+b+";\n");
        bw.write("String str ="+str+";\n");

        String temp=null;
        while ((temp=br.readLine())!=null){
            System.out.println(temp);
            bw.flush();
        }
        bw.close();
        br.close();

    }
}
